package cn.ml.utils.shiJianChuo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Time02 {
    public static void main(String[] args) throws ParseException {
        System.out.println("****************** Date -> String ******************");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        String date = df.format(new Date());// new Date()为获取当前系统时间，也可使用当前时间戳
        System.out.println(date);
        System.out.println(date instanceof String);

        System.out.println("****************** String -> Date ******************");
        /*SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd");
        String s= "2011-07-09 ";
        Date date2 = formatter.parse(s);*/
        Date date2 = df.parse(date);
        System.out.println(date2);
        System.out.println(date2 instanceof Date);

    }
}
